package com.szqhyxj.youxiangju.biz.partnerHome.equipment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.szqhyxj.youxiangju.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * XiaoPanYu
 * on 2018/11/22
 */
public class NumberAdapter extends BaseAdapter{

    private List<String> devices;

    public NumberAdapter( List<String> devices){
        this.devices = devices;
    }

    @Override
    public int getCount(){
        return devices.size();
    }

    @Override
    public Object getItem(int i){
        return devices.get(i);
    }

    @Override
    public long getItemId(int i){
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup){
        if(view == null){
            view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.list_equipment_number_itme, null);
            ViewHolder holder = new ViewHolder(view);
            view.setTag(holder);
        }
        ViewHolder holder = (ViewHolder) view.getTag();
        holder.device.setText(devices.get(i));

        return view;
    }

    static class ViewHolder{
        @BindView(R.id.device)
        TextView device;

        ViewHolder(View view){
            ButterKnife.bind(this, view);
        }
    }
}
